﻿
--|--------------------------------------------------------------------------------
--| [GetTrack] - Insert Procedure Script for GPSPoint
--|--------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id (N'[dbo].[GetTrack]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) 
  DROP PROCEDURE [dbo].[GetTrack]
GO

CREATE PROCEDURE [dbo].[GetTrack]
(
	@GameName nvarchar(50),
	@EntityName nvarchar(50),
	@Period int
)
AS
	SET NOCOUNT ON
	
	SELECT 	
		[EntityID] as ID,
		[EntityName] as [Name],
		[Latitude],
		[Longitude],
		[Time],
		[Speed],
		[Altitude]

	FROM [GPSPoint]
	WHERE [GameName] = @GameName
		AND [EntityName] = @EntityName
		AND Time > DateAdd(s,-@Period,GetDate())
	ORDER BY Time
	
GO
 